export enum EOperationType {
  LOGIN = '001001',
  LOGOUT = '001002',
  ADDUSER = '002001',
  EDITUSER = '002002',
  DELUSER = '002003',
  RESETPWD = '002004',
}

interface IRecordCodeMap {
  [key: string]: {
    category: string;
    code: string;
    message: (subject: string, object?: string) => string;
  };
}

const recordCodeMap: IRecordCodeMap = {
  [EOperationType.LOGIN]: {
    category: 'system',
    code: EOperationType.LOGIN,
    message: subject => `${subject}登陆了系统`,
  },
  [EOperationType.LOGOUT]: {
    category: 'system',
    code: EOperationType.LOGOUT,
    message: subject => `${subject}退出登陆`,
  },
  [EOperationType.ADDUSER]: {
    category: 'user',
    code: EOperationType.ADDUSER,
    message: (subject, object) => `${subject}新增了用户${object}`,
  },
  [EOperationType.EDITUSER]: {
    category: 'user',
    code: EOperationType.EDITUSER,
    message: (subject, object) => `${subject}修改了用户${object}的信息`,
  },
  [EOperationType.DELUSER]: {
    category: 'user',
    code: EOperationType.DELUSER,
    message: (subject, object) => `${subject}删除了用户${object}`,
  },
  [EOperationType.RESETPWD]: {
    category: 'user',
    code: EOperationType.RESETPWD,
    message: (subject, object) => `${subject}重置了用户${object}的密码`,
  },
};

export default recordCodeMap;
